package com.airena.controller;

import com.airena.entity.po.RoleCategory;
import com.airena.result.Result;
import com.airena.service.IRoleCategoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 角色分类接口
 */
@RestController
@RequestMapping("/role-categories")
@Slf4j
@Tag(name = "角色分类接口")
public class RoleCategoryController {

    @Autowired
    private IRoleCategoryService roleCategoryService;

    /**
     * 获取所有角色分类
     *
     * @return 角色分类列表
     */
    @GetMapping
    @Operation(summary = "获取所有角色分类")
    public Result<List<RoleCategory>> listAllRoleCategories() {
        log.info("获取所有角色分类");
        List<RoleCategory> roleCategories = roleCategoryService.list();
        return Result.success(roleCategories);
    }
    
    /**
     * 根据分类ID获取角色分类详情
     *
     * @param categoryId 分类ID
     * @return 角色分类详情
     */
    @GetMapping("/{categoryId}")
    @Operation(summary = "根据分类ID获取角色分类详情")
    public Result<RoleCategory> getRoleCategoryById(@PathVariable Integer categoryId) {
        log.info("根据分类ID获取角色分类详情: categoryId={}", categoryId);
        RoleCategory roleCategory = roleCategoryService.getById(categoryId);
        return Result.success(roleCategory);
    }
}